package logic

import (
	"baidutieba/models/mysql"
	"context"
	"gorm.io/gorm"

	"baidutieba/tiebarpc/internal/svc"
	"baidutieba/tiebarpc/tiebarpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type PerfectLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewPerfectLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PerfectLogic {
	return &PerfectLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *PerfectLogic) Perfect(in *tiebarpc.PerfectRequest) (*tiebarpc.PerfectResponse, error) {
	// todo: add your logic here and delete this line
	user := mysql.User{
		Model: gorm.Model{ID: uint(in.UserId)},

		UserImage: in.UserImage,
		Info:      in.Info,
		NickName:  in.NickName,
	}
	mysql.DB.Updates(&user)
	return &tiebarpc.PerfectResponse{
		Id: in.UserId,
	}, nil
}
